package com.spring.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.spring.dao.*;
import com.spring.entity.*;
import com.spring.service.*;
import com.spring.util.*;
import java.util.*;
import java.util.*;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

@Service("AddressService")
public class AddressServicelmpl implements AddressService {
    @Resource
    private AddressMapper dao;

    @Override
    public List<Address> select() { return dao.select(null); }

    @Override
    public List<Address> select(Address y) { return dao.select(y); }

    @Override
    public Address find(Object id) { return dao.selectByPrimaryKey(id); }

    @Override
    public Address findEntity(Address id) { return dao.selectOne(id); }

    @Override
    public List<Address> selectPage(Address obj, int page, int pageSize) {
        PageHelper.startPage(page, pageSize, true);
        List<Address> list = select(obj);
        PageInfo<Address> pageInfo = new PageInfo(list);
        PageInfoUtil pageInfoUtil = new PageInfoUtil(page);
        pageInfoUtil.setPageInfo(Request.getRequest(), pageInfo.getTotal(), pageSize);
        return list;
    }

    @Override
    public List<Address> selectPageExample(Example obj, int page, int pageSize) {
        PageHelper.startPage(page, pageSize, true);
        List<Address> list = dao.selectByExample(obj);
        PageInfo<Address> pageInfo = new PageInfo(list);
        PageInfoUtil pageInfoUtil = new PageInfoUtil(page);
        pageInfoUtil.setPageInfo(Request.getRequest(), pageInfo.getTotal(), pageSize);
        return list;
    }

    @Override
    public int delete(Object id) {
        return dao.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(Address y) {
        return dao.insertSelective(y);
    }

    @Override
    public int update(Address y) {
        return dao.updateByPrimaryKeySelective(y);
    }
}
